﻿using AlipayPay.Api.Controllers.Common;
using AlipayPay.Domain;
using AlipayPay.Domain.Model.Interface;
using AlipayPay.Infrastructure.Api;
using AlipayPay.Infrastructure.EntitiyExtensions;
using AlipayPay.Repository.MySql.Infrastructure;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace AlipayPay.Api.Controllers
{
    public class CheckController : BaseController
    {
        private readonly IUsersRepository _usersRepository;

        private readonly IQuery<ShoppingCart> _shoppingCartQuery;

        public CheckController(IUsersRepository usersRepository,
            IQuery<ShoppingCart> shoppingCartQuery)
        {
            _usersRepository = usersRepository;
            _shoppingCartQuery = shoppingCartQuery;
        }

        [HttpGet]
        public async Task<JsonResult> Get()
        {
            var bb=await _usersRepository.Get();
            var aaa = await _shoppingCartQuery.GetQueryable().ToListAsync();

            return Json(aaa);
        }

        /// <summary>
        /// 测试添加
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<JsonResult> Add()
        {
            ShoppingCart a = new Domain.ShoppingCart()
            {
               
            };
            _usersRepository.AddAsync(a);

            return await CommitUofAndFormatMsgAsync(() => new ApiUpdateResult(true));
        }
    }
}
